const express = require('express');
const router = express.Router();
const data = [];
const listData = [];
for(let i = 1; i < 51; i++)
    data.push({
        id: `${i}`,
        code: `QH2019082700-${i}`,
        brandCode: 'QR',
        brandName: '奇瑞',
        dealerCode: '10145',
        dealerName: '总代名称10145',
        invoiceCode: 'FP20190827001',
        invoicedDate: '2019-09-04T02:37:44.918Z',
        status: 1,
        claimType: 1,
        paymentMethod: 1,
        currency: 1,
        claimFee: 98655,
        claimAmount: 10,
        createTime: '2019-09-04T02:37:44.918Z',
        submitTime: '2019-09-04T02:37:44.918Z',
        approverTime: '2019-09-04T02:37:44.918Z',
        rowVersion: 'string',
        options: ['update', 'submit', 'approve', 'abandon']
    });
router.get('/forCurrentUser', (req, res) => {
    const {pageIndex, pageSize} = req.query;
    res.json({
        message: 'ok',
        payload: {
            content: data,
            pageIndex: parseInt(pageIndex, 10),
            pageSize: parseInt(pageSize, 10),
            totalElements: 50
        }
    });
});

for(let i = 1; i < 51; i++)
    listData.push({
        id: `${i}`,
        code: '6546521785',
        claimId: '2134',
        dealerCode: '001',
        brandCode: 'QR',
        brandName: '奇瑞',
        claimType: 1,
        invoiceCode: 'FP20190827001',
        invoicedDate: '2019-09-04T02:37:44.918Z',
        currency: 1,
        paymentMethod: 1,
        receiptDate: '2019-09-04T02:37:44.918Z',
        shipmentDate: '2019-09-04T02:37:44.918Z',
        actualArrivalDate: '2019-09-04T02:37:44.918Z',
        address: '重庆市渝北区',
        contactNumber: '178978981424',
        destination: '上海',
        claimAmount: 120,
        mgmtRate: 1.8,
        partClaimReportDetail: [
            {
                partId: '1',
                packingListCode: '4231564641',
                partSaleOrderCode: '2131321',
                partCode: '001',
                partName: 'partName',
                claimAmount: 120,
                price: 120,
                quantity: 20,
                claimReason: 1,
            }, {
                partId: '2',
                packingListCode: '4231564642',
                partSaleOrderCode: '2131322',
                partCode: '002',
                partName: 'partName',
                claimAmount: 120,
                price: 120,
                quantity: 20,
                claimReason: 2,
            }
        ]
    });

router.get('/forPartClaimReport', (req, res) => {
    const {pageIndex, pageSize} = req.query;
    res.json({
        message: 'ok',
        payload: {
            content: listData,
            pageIndex: parseInt(pageIndex, 10),
            pageSize: parseInt(pageSize, 10),
            totalElements: 50
        }
    });
});


router.get('/:id', (req, res) => {
    res.json({
        message: 'ok',
        payload: {
            id: '1',
            code: 'QH2019082700-1',
            brandCode: 'QR',
            brandName: '奇瑞',
            dealerCode: '10145',
            dealerName: '总代名称10145',
            invoiceCode: 'FP20190827001',
            invoicedDate: '2019-09-04T02:37:44.918Z',
            status: 1,
            claimType: 1,
            paymentMethod: 1,
            currency: 1,
            claimFee: 98655,
            claimAmount: 10,
            createTime: '2019-09-04T02:37:44.918Z',
            submitTime: '2019-09-04T02:37:44.918Z',
            approverTime: '2019-09-04T02:37:44.918Z',
            rowVersion: 'string',
            options: ['update', 'submit', 'approve', 'abandon'],
            partInvoiceId: '1',
            brandId: '1',
            dealerId: '1',
            address: '上海黄浦区',
            contactNumber: '4008888001',
            branchCode: 'QR',
            branchName: '奇瑞',
            shipmentDate: '2019-09-04T02:37:44.918Z',
            actualArrivalDate: '2019-09-04T02:37:44.918Z',
            destination: '巴西',
            receiptDate: '2019-09-04T02:37:44.918Z',
            creatorName: '1test',
            modifierName: 'test',
            modifyTime: '2019-09-04T02:37:44.918Z',
            submitterName: 'test',
            approverName: 'test',
            abandonerName: 'test',
            abandonTime: '2019-09-04T02:37:44.918Z',
            remark: 'string',
            details: [
                {
                    invoicePackingListDetailId: '1',
                    packingListCode: 'XD2019098001',
                    partSaleOrderCode: 'XS2019098001',
                    partId: '1',
                    partCode: 'partCode1',
                    partName: 'partName1',
                    quantity: 3,
                    price: 4,
                    claimAmount: 6,
                    claimFee: 7,
                    claimReason: 1,
                    attachments: [
                        {
                            fileId: '1',
                            fileName: '附件1'
                        }, {
                            fileId: '2',
                            fileName: '附件2'
                        }, {
                            fileId: '3',
                            fileName: '附件3'
                        },
                    ]
                },
                {
                    invoicePackingListDetailId: '2',
                    packingListCode: 'XD2019098002',
                    partSaleOrderCode: 'XS2019098002',
                    partId: '2',
                    partCode: 'partCode2',
                    partName: 'partName2',
                    quantity: 3,
                    price: 4,
                    claimAmount: 6,
                    claimFee: 7,
                    claimReason: 2,
                    attachments: [
                        {
                            fileId: '1',
                            fileName: '附件1'
                        }, {
                            fileId: '2',
                            fileName: '附件2'
                        }, {
                            fileId: '3',
                            fileName: '附件3'
                        },
                    ]
                },
                {
                    invoicePackingListDetailId: '3',
                    packingListCode: 'XD2019098003',
                    partSaleOrderCode: 'XS2019098003',
                    partId: '3',
                    partCode: 'partCode3',
                    partName: 'partName3',
                    quantity: 3,
                    price: 4,
                    claimAmount: 6,
                    claimFee: 7,
                    claimReason: 3,
                    attachments: [
                        {
                            fileId: '1',
                            fileName: '附件1'
                        }, {
                            fileId: '2',
                            fileName: '附件2'
                        }, {
                            fileId: '3',
                            fileName: '附件3'
                        },
                    ]
                }
            ]
        }
    });
});
router.post('/', (req, res) => {
    res.json({
        message: '新增'
    });
});
router.put('/', (req, res) => {
    res.json({
        message: '编辑'
    });
});
router.put('/:id/submit', (req, res) => {
    res.json({
        message: '提交'
    });
});
router.put('/:id/pass', (req, res) => {
    res.json({
        message: '审核通过'
    });
});
router.put('/:id/reject', (req, res) => {
    res.json({
        message: '驳回'
    });
});
router.put('/:id/refuse', (req, res) => {
    res.json({
        message: '拒赔'
    });
});
router.put('/:id/abandon', (req, res) => {
    res.json({
        message: '作废'
    });
});
router.get('/export/forCurrentUser', (req, res) => {
    res.json({
        message: '导出'
    });
});
module.exports = router;
